<script>
  init({
    title: 'Modal Table',
    desc: 'Use Bootstrap Table in a modal. We need to call `resetView` method after modal shown.',
    links: ['bootstrap-table.min.css'],
    scripts: ['bootstrap-table.min.js']
  })
</script>

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#modalTable">
  Launch modal table
</button>
<div id="modalTable" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal table</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <table id="table"
          data-toggle="table"
          data-height="299"
          data-url="json/data1.json">
          <thead>
            <tr>
              <th data-field="id">ID</th>
              <th data-field="name">Item Name</th>
              <th data-field="price">Item Price</th>
            </tr>
          </thead>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<script>
  var $table = $('#table')

  function mounted() {
    $('#modalTable').on('shown.bs.modal', function () {
      $table.bootstrapTable('resetView')
    })
  }
</script>
